package com.lhy.tool.patchplugin.strategy;

import com.lhy.tool.patchplugin.model.SrcFileWrapper;

import java.io.File;
import java.util.Collections;
import java.util.List;

/**
 * springboot jar包策略类
 */
public class SpringBootJarStrategyImpl extends SimpleFileStrategy {

    private static final String ZZFW_API = "zzfw-api";
    private static final String ZZFW_API_JAR = "/" + ZZFW_API + ".jar";
    private static final String ZZFW_INTERFACE = "zzfw-interface";
    private static final String TARGET = "/target";

    public SpringBootJarStrategyImpl(List<String> targetForderPaths) {
        super(targetForderPaths);
    }

    @Override
    public boolean accept(SrcFileWrapper srcFileWrapper) {
        return srcFileWrapper.getAbsolutePath().startsWith(patchPluginProperties.getSrcPath() + ZZFW_INTERFACE);
    }

    @Override
    protected List<File> getCompileFileList(SrcFileWrapper srcFileWrapper) {
        File compileFile = new File(patchPluginProperties.getSrcPath() + ZZFW_INTERFACE + "/" + ZZFW_API + TARGET + ZZFW_API_JAR);
        return Collections.singletonList(compileFile);
    }
}
